import { ref } from 'vue';
import dayjs from 'dayjs';
import AddProduce from '../../modal/add-produce.vue';

const visible = ref(false);
const currentRow = ref(null);
const modalOperateType = ref('add');

export default {
  url: '/qms/electroGold/produce/list',
  addUrl: '/qms/electroGold/produce/add',
  editUrl: '/qms/electroGold/produce/update',
  delUrl: '/qms/electroGold/produce/deleteBatch',
  modalGetTableDataUrl: '/qms/electroGold/produce/',
  editMethod: 'put',
  rednderComponents: [
    () => {
      return (
        <AddProduce
          visible={visible.value}
          rowData={currentRow.value}
          operateType={modalOperateType.value}
          onAddModalClose={() => (visible.value = false)}
          onAddSuccess={() => {}}
        ></AddProduce>
      );
    }
  ],
  // 表头搜索栏目
  searchFormList: [
    {
      type: 'input',
      key: 'moduleNo',
      label: '生产型号',
      placeholder: '请输入生产型号',
      span: 24,
      md: 12,
      lg: 8,
      xl: 8,
      xxl: 6
    },
    {
      type: 'input',
      key: 'lotId',
      label: 'LOT号',
      placeholder: '请输入LOT号',
      span: 24,
      md: 12,
      lg: 8,
      xl: 8,
      xxl: 6
    },
    {
      type: 'input',
      key: 'serialNum',
      label: '单据号',
      placeholder: '请输入单据号',
      span: 24,
      md: 12,
      lg: 8,
      xl: 8,
      xxl: 6
    },
    {
      type: 'select',
      key: 'state',
      label: '审核状态',
      placeholder: '请选择审核状态',
      span: 24,
      md: 12,
      lg: 8,
      xl: 8,
      xxl: 6,
      selectOptions: [
        {
          value: '0',
          label: '待领班审核'
        },
        {
          value: '1',
          label: '待修改'
        },
        {
          value: '2',
          label: '待主管审核'
        },
        {
          value: '3',
          label: '审核完成'
        }
      ]
    },
    {
      type: 'select',
      key: 'shiftType',
      label: '班别',
      placeholder: '请选择班别',
      span: 24,
      md: 12,
      lg: 8,
      xl: 8,
      xxl: 6,
      selectOptions: [
        {
          value: '0',
          label: '白班'
        },
        {
          value: '1',
          label: '夜班'
        }
      ]
    },

    {
      type: 'dateRangePicker',
      key: 'time',
      label: '日期',
      span: 24,
      md: 12,
      lg: 10,
      xl: 8,
      xxl: 6
    }
  ],
  searchParam: ref({
    moduleNo: null,
    lotId: null,
    state: null,
    shiftType: null,
    time: null
  }),
  // 新增信息
  column: [
    {
      key: 'dataIndex',
      dataIndex: 'dataIndex',
      title: '序号',
      width: 70,
      fixed: 'left',
      align: 'center',
      checked: true,
      ellipsis: true
    },
    {
      key: 'moduleNo',
      dataIndex: 'moduleNo',
      title: '生产型号',
      width: 150,
      align: 'center',
      fixed: 'left',
      checked: true,
      ellipsis: true
    },
    {
      key: 'lotId',
      dataIndex: 'lotId',
      title: 'LOT号',
      width: 150,
      align: 'center',
      fixed: 'left',
      checked: true,
      ellipsis: true
    },
    {
      key: 'serialNum',
      dataIndex: 'serialNum',
      title: '单据号',
      width: 130,
      align: 'center',
      fixed: 'left',
      checked: true,
      ellipsis: true
    },
    {
      key: 'state',
      dataIndex: 'state',
      title: '状态',
      width: 120,
      align: 'center',
      checked: true,
      ellipsis: true,
      customRender: ({ record }) => {
        return ['待领班审核', '待修改', '待主管审核', '审核完成'][record.state];
      }
    },
    {
      key: 'time',
      dataIndex: 'time',
      title: '录入时间',
      width: 170,
      align: 'center',
      checked: true,
      ellipsis: true
    },
    {
      key: 'quantity',
      dataIndex: 'quantity',
      title: '数量',
      width: 100,
      align: 'center',
      checked: true,
      ellipsis: true
    },
    {
      key: 'meridional',
      dataIndex: 'meridional',
      title: '板长(mm)',
      width: 110,
      align: 'center',
      checked: true,
      ellipsis: true
    },

    {
      key: 'zonal',
      dataIndex: 'zonal',
      title: '板宽(mm)',
      width: 110,
      align: 'center',
      checked: true,
      ellipsis: true
    },

    {
      key: 'goldArea',
      dataIndex: 'goldArea',
      title: '金面积%',
      width: 100,
      align: 'center',
      checked: true,
      ellipsis: true
    },

    {
      key: 'eletricGoldAddArea',
      dataIndex: 'eletricGoldAddArea',
      title: '累计面积㎡',
      width: 120,
      align: 'center',
      checked: true,
      ellipsis: true
    },
    {
      key: 'electricGlodRequired',
      dataIndex: 'electricGlodRequired',
      title: '金厚要求um',
      width: 120,
      align: 'center',
      checked: true,
      ellipsis: true
    },

    {
      key: 'glodTimeDensity',
      dataIndex: 'glodTimeDensity',
      title: '金电流设定时间/密度',
      width: 180,
      align: 'center',
      checked: true,
      ellipsis: true
    },

    {
      key: 'electricNickelRequired',
      dataIndex: 'electricNickelRequired',
      title: '镍厚要求um',
      width: 140,
      align: 'center',
      checked: true,
      ellipsis: true
    },
    {
      key: 'nickelTimeDensity',
      dataIndex: 'nickelTimeDensity',
      title: '镍电流设定时间/密度',
      width: 170,
      align: 'center',
      checked: true,
      ellipsis: true
    },
    // 班别和备注
    {
      key: 'shiftType',
      dataIndex: 'shiftType',
      title: '班别',
      width: 120,
      align: 'center',
      checked: true,
      ellipsis: true,
      customRender: ({ record }) => {
        return ['白班', '夜班'][record.shiftType];
      }
    },
    ,
    // 药水补加部分
    // 药水补加部分
    {
      key: 'potionLabel1',
      dataIndex: 'potionLabel1',
      title: '除油',
      width: 170,
      align: 'center',
      checked: true,
      ellipsis: true
    },
    {
      key: 'potionLabel2',
      dataIndex: 'potionLabel2',
      title: '微蚀',
      width: 170,
      align: 'center',
      checked: true,
      ellipsis: true
    },

    {
      key: 'potionLabel3',
      dataIndex: 'potionLabel3',
      title: '磺酸洗',
      width: 170,
      align: 'center',
      checked: true,
      ellipsis: true
    },

    {
      key: 'potionLabel4',
      dataIndex: 'potionLabel4',
      title: '镍缸',
      width: 170,
      align: 'center',
      checked: true,
      ellipsis: true
    },

    {
      key: 'potionLabel5',
      dataIndex: 'potionLabel5',
      title: '镍缸光剂',
      width: 170,
      align: 'center',
      checked: true,
      ellipsis: true
    },

    {
      key: 'potionLabel6',
      dataIndex: 'potionLabel6',
      title: '酸活化',
      width: 170,
      align: 'center',
      checked: true,
      ellipsis: true
    },
    {
      key: 'potionLabel7',
      dataIndex: 'potionLabel7',
      title: '金缸',
      width: 170,
      align: 'center',
      checked: true,
      ellipsis: true
    },

    {
      key: 'operator',
      dataIndex: 'operator',
      title: '操作员',
      width: 110,
      align: 'center',
      checked: true,
      ellipsis: true
    },

    {
      key: 'foreman',
      dataIndex: 'foreman',
      title: '领班审核',
      width: 100,
      align: 'center',
      checked: true,
      ellipsis: true
    },
    {
      key: 'foremanTime',
      dataIndex: 'foremanTime',
      title: '领班审核时间',
      width: 180,
      align: 'center',
      checked: true,
      ellipsis: true
    },
    {
      key: 'examiner',
      dataIndex: 'examiner',
      title: '主管审核',
      width: 100,
      align: 'center',
      checked: true,
      ellipsis: true
    },
    {
      key: 'examinerTime',
      dataIndex: 'examinerTime',
      title: '主管审核时间',
      width: 180,
      align: 'center',
      checked: true,
      ellipsis: true
    },
    {
      key: 'remark',
      dataIndex: 'remark',
      title: '备注',
      width: 180,
      align: 'center',
      checked: true,
      ellipsis: true
    },
    {
      key: 'createTime',
      dataIndex: 'createTime',
      title: '创建时间',
      width: 180,
      align: 'center',
      checked: true,
      ellipsis: true,
      customRender: ({ record }) => {
        return dayjs(record.createTime).format('YYYY-MM-DD HH:mm:ss');
      }
    },
    {
      key: 'updateTime',
      dataIndex: 'updateTime',
      title: '修改时间',
      width: 180,
      align: 'center',
      checked: true,
      ellipsis: true
    },
    {
      key: 'updateBy',
      dataIndex: 'updateBy',
      title: '修改人',
      width: 100,
      align: 'center',
      checked: true,
      ellipsis: true
    }
  ],

  scroll: { x: 2500, y: 'auto' },
  modalGetTableUrlSuffix: {
    add: 'selectBadId',
    byId: 'listBad'
  },
  modleSearchUrlObj: {
    lotId: '/rcerp/agv/erp/findByLotNo',
    moduleNo: '/rcerp/agv/erp/findByModuleNo'
  },

  isCustomAdd: true,
  openModal(val) {
    visible.value = true;
    currentRow.value = val.currentRow;
    modalOperateType.value = val.operateType;
  }
};
